package diandiansong.library.utils;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

/**
 * Created by act on 2017/6/12.
 */

public class BaseEntity implements Serializable {


    /**
     * status_code : 1
     * message : 登录成功
     * data : {"token":"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzIxMjMxMjMxMSIsImlzcyI6Imh0dHA6XC9cL2gxLm1vYmlsZWtvdWRhaS5jb21cL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOiIxNTMxMjc4MTQ1IiwiZXhwIjoiMTUzMTg4Mjk0NSIsIm5iZiI6IjE1MzEyNzgxNDUiLCJqdGkiOiI0NzNkN2I2OWQwMjA3MmNkZDM5NDY3ZGUwZjQ1MzMyZCJ9.BbDsdIFeJxEi_MD12G2YSbCbum_-ksiVSNt-0v8kRgI"}
     */

    @SerializedName("status_code")
    private String statusCode;
    @SerializedName("message")
    private Object message;

    public String getStatusCode() {
        return statusCode;
    }

    public int getStatusCodeInt() {
        int value = 0;
        try {
            value = Integer.valueOf(statusCode);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return value;
    }

    public void setStatusCode(String statusCode) {
        this.statusCode = statusCode;
    }

    public String getMessage() {
        return (String)message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isSuccess() {
        return statusCode != null && statusCode.equals("1");
    }

    public boolean isAuthError() {
        return statusCode != null && statusCode.equals("401");
    }

}
